package question5.com.qee.jdbc;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import java.sql.Connection;
import java.sql.SQLException;

public class HikariSession extends DefaultSession implements Session {


    private static final HikariDataSource hikariDataSource;

    @Override
    public Connection createConnection() {
        try {
            connection = hikariDataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            return null;
        }
        return connection;
    }

    static {
        HikariConfig conf = new HikariConfig();
        conf.setUsername("root");
        conf.setPassword("root");
        conf.setJdbcUrl("jdbc:mysql://localhost:3306/test");
        hikariDataSource = new HikariDataSource(conf);
    }


}
